#pragma once

#include <stdio.h>
#include <stdlib.h>
#include "esp_log.h"
#include "driver/gpio.h"
#include "driver/adc.h"
#include "esp_adc_cal.h"


static const adc1_channel_t channel = ADC1_CHANNEL_0;     //GPIO36 if ADC1
static const adc_bits_width_t width = ADC_WIDTH_BIT_12;

static const adc_atten_t atten = ADC_ATTEN_DB_11;   //150~2450mV
//ADC_ATTEN_DB_0:表示参考电压为1.1V
//ADC_ATTEN_DB_2_5:表示参考电压为1.5V
//ADC_ATTEN_DB_6:表示参考电压为2.2V
//ADC_ATTEN_DB_11:表示参考电压为3.9V
#define DEFAULT_VREF    1100        //Use adc2_vref_to_gpio() to obtain a better estimate

class My_ADC{
    public:
        My_ADC(adc1_channel_t,adc_bits_width_t,adc_atten_t);
        void get_voltage();
        uint32_t Voltage;
        uint32_t read_raw;
        uint8_t Level;
        uint8_t Value_Level;

    private:
        adc1_channel_t      _channel;
        adc_bits_width_t    _width;
        adc_atten_t         _atten;

};

